<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
    <div id="app">
      精度：<input type="text" v-model="lng">
      <hr>
      维度：<input type="text" v-model="lat">
      <hr>
      <button @click="toLoad">查询</button>
      <div v-if="addRes.address">
        <h1>{{addRes.address}}</h1>
         <h1>{{addRes.address_component.province}}</h1>
        <h1>{{addRes.address_component.city}}</h1>
          <h1>{{addRes.address_component.city}}</h1>
      </div>
    </div>
    <script src="./vue.js"></script>
    <script>
      new Vue({
        el:"#app",
        data(){
          return {
            lng:"", //精度
            lat:"",//维度
            addRes:{}
          }
        },
        methods: {
          toLoad(){
            let xhr=new XMLHttpRequest()
            xhr.open("post","https://api.oioweb.cn/api/ip/geocoder",true)

            xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");

            xhr.send(`lng=${this.lng}&lat=${this.lat}`)
            xhr.onreadystatechange=()=>{
              if(xhr.status==200){
                console.log(xhr.responseText)
                this.addRes=JSON.parse(xhr.responseText).result;
              }
            }

          }
        },  
      })
    </script>
</body>
</html>